package hot;

public class Num621 {
    public int leastInterval(char[] tasks, int n) {
        int[] nums = new int[26];
        for(char c : tasks) {
            nums[c - 'A'] += 1;
        }
        int max = 0;
        for(int i = 0 ; i < 26; i++) {
            max = Math.max(max,nums[i]);
        }
        int time = (max - 1) * (n + 1);
        for(int i : nums) {
            if(i == max) {
                time++;
            }
        }
        return Math.max(time,tasks.length);
    }
}
